package biz.obake.team.touchprotector.notice;

import android.view.View;
import androidx.preference.l;
import biz.obake.team.touchprotector.R;

public class ClosableNotice extends Notice {
    static final String PREF_CLOSED_SUFFIX = "_closed";
    static final String PREF_SINCE_SUFFIX = "_since";

    class a implements View.OnClickListener {
        a() {
        }

        public void onClick(View view) {
            ClosableNotice.this.close();
        }
    }

    class b implements View.OnClickListener {

        /* renamed from: b  reason: collision with root package name */
        final /* synthetic */ NoticePreference f1776b;

        b(ClosableNotice closableNotice, NoticePreference noticePreference) {
            this.f1776b = noticePreference;
        }

        public void onClick(View view) {
            this.f1776b.i().startActivity(this.f1776b.n());
        }
    }

    private boolean beingDelayed() {
        if (!this.mAttributes.containsKey(":delay")) {
            return false;
        }
        long parseLong = Long.parseLong(this.mAttributes.get(":delay")) * 24 * 60 * 60 * 1000;
        long currentTimeMillis = System.currentTimeMillis();
        String str = "notice_" + this.mGuid + PREF_SINCE_SUFFIX;
        if (biz.obake.team.touchprotector.g.a.a(str)) {
            return currentTimeMillis - Long.parseLong(biz.obake.team.touchprotector.g.a.l(str)) < parseLong;
        }
        biz.obake.team.touchprotector.g.a.r(str, Long.toString(currentTimeMillis));
        return true;
    }

    private boolean isHiddenUpdate() {
        return this.mAttributes.containsKey(":update") && biz.obake.team.touchprotector.g.a.j("first_version_code") >= Integer.parseInt(this.mAttributes.get(":update"));
    }

    /* access modifiers changed from: package-private */
    public void close() {
        biz.obake.team.touchprotector.g.a.p("notice_" + this.mGuid + PREF_CLOSED_SUFFIX, true);
    }

    public boolean isAlerted() {
        if (!isClosed() && !beingDelayed() && !isHiddenUpdate()) {
            return super.isAlerted();
        }
        return false;
    }

    /* access modifiers changed from: package-private */
    public boolean isClosed() {
        return biz.obake.team.touchprotector.g.a.g("notice_" + this.mGuid + PREF_CLOSED_SUFFIX);
    }

    public boolean isVisible() {
        if (!isClosed() && !beingDelayed() && !isHiddenUpdate()) {
            return super.isVisible();
        }
        return false;
    }

    /* access modifiers changed from: package-private */
    public void onBindViewHolder(l lVar, NoticePreference noticePreference) {
        super.onBindViewHolder(lVar, noticePreference);
        View M = lVar.M(R.id.closeButton);
        if (M != null) {
            M.setOnClickListener(new a());
        }
        View M2 = lVar.M(R.id.intentButton);
        if (M2 != null && noticePreference.n() != null) {
            M2.setOnClickListener(new b(this, noticePreference));
        }
    }

    /* access modifiers changed from: package-private */
    public void onPrefChanged(String str) {
        if (("notice_" + this.mGuid + PREF_CLOSED_SUFFIX).equals(str)) {
            update();
        }
    }

    public void reopen() {
        biz.obake.team.touchprotector.g.a.p("notice_" + this.mGuid + PREF_CLOSED_SUFFIX, false);
    }
}
